package com.baizhi.controller;

import com.baizhi.entity.User;
import com.baizhi.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Controller
@ResponseBody
@RequestMapping("index")
public class IndexController {

    @Resource
    private UserService userService;

    /*查询一个人*/
    @RequestMapping(value = "/find/{id}")
    public void findUser(@PathVariable("id") String id){
        User user = userService.getUser(id);
        System.out.println(user);
    }

    /*查询全部*/
    @RequestMapping(value = "/findall")
    public List<User> findAll(){
        List<User> all = userService.findAll();
        return all;
    }

}
